<?php

namespace App\Http\Resources\Admin\V1;

use Illuminate\Http\Resources\Json\JsonResource;

class MenuResource extends JsonResource
{
    /**
     * @param \Illuminate\Http\Request $request
     * @return array
     * @author cwc
     */
    public function toArray($request)
    {
        return [
            'id'             => (int) $this->id,//菜单ID
            'parent_id'      => (int) $this->parent_id,//上级菜单ID
            'icon'           => (string) $this->icon,//菜单图标
            'name'           => (string) $this->name,//菜单名称
            'title'          => (string) $this->title,//菜单标题
            'path'           => (string) $this->path,//URL路径
            'component_path' => (string) $this->component_path,//模板路径
            'is_enable'      => (int) $this->is_enable,//是否启用
            'created_time'   => (int) strtotime($this->created_time),//创建时间
            'updated_time'   => (int) strtotime($this->updated_time),//更新时间
        ];
    }
}
